<!-- BEGIN PAGE HEADER-->
<?php $this->load->view('partials/breadcrumb.tpl',  Array('_NO_IOSS_NEW'=>'1'))?>
<!-- END PAGE HEADER-->
<!-- BEGIN PAGE CONTENT-->
<link rel="stylesheet" type="text/css" href="<?=site_url('/static/js/jquery.toast.min.css')?>"/>
<script type="text/javascript" src="<?=site_url('/static/js/jquery.toast.min.js')?>"></script>
<script type="text/javascript">
function modify_row(row_id){
	var reNum = /^[1-9]+[0-9]*]*$/;		//判断是否为正整数正则
	var phone_input = $('#phone_'+row_id);
	var friend_num_input = $('#friend_num_'+row_id);
	var awards_num_input = $('#awards_num_'+row_id);
	if(!reNum.test(friend_num_input.val())){
		alert('好友数量需为正整数！');
		friend_num_input.focus();
		return false;
	}
	if(!reNum.test(awards_num_input.val())){
		alert('红包数量需为正整数！');
		awards_num_input.focus();
		return false;
	}
	var params = {
			id:row_id,
			phone:phone_input.val(),
			friend_num:friend_num_input.val(),
			awards_num:awards_num_input.val()
		};
	
	$.post("<?=site_url($thisModule.$thisController.'/modifyrow/')?>",params,function(ret){
		var retObj = $.parseJSON(ret);
		if(retObj.code < 0){
			alert(retObj.message);
			return;
		}
		createToast('success','修改成功');
	});
	
}

function createToast(t,message=''){
				var options = {
					duration: Math.floor(Math.random() * 4001) + 1000,
					sticky: !!Math.round(Math.random() * 1),
					type: t
				};
				$.toast(message, options);
			}
			
</script>
<div class="row">
	<div class="col-md-12">
		<!-- Begin: life time stats -->
		<div class="portlet">
			<div class="portlet-body">
				<div class="row">
					<div class="col-md-12">
						<div class="table-scrollable">
							<table class="table table-hover table-bordered table-striped">
								<thead>
								<tr>
									<th>用户编号</th>				
									<th>用户账号</th>
									<th>好友数量</th>
									<th>红包数量</th>
									<th>操作</th>
								</tr>
								</thead>
								<tbody>
								<?php  foreach ($list as $item){	?>
									<tr>
										<td><?=htmlspecialchars($item->id)?></td>
										<td><input id="phone_<?=$item->id?>" type="text" value="<?=$item->phone?>"/></td>
										<td><input id="friend_num_<?=$item->id?>" type="text" value="<?=$item->friend_num?>"/></td>
										<td><input id="awards_num_<?=$item->id?>" type="text" value="<?=$item->awards_num?>"/></td>
										<td><a href="javascript:modify_row('<?=$item->id?>')" class="btn btn-sm green">修改</a></td>
									</tr>
								<?php }?>
								</tbody>
							</table>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-md-12 text-right">
						<?=$pagination?>
					</div>
				</div>
			</div>
		</div>
		<!-- End: life time stats -->
	</div>
</div>

<!-- END PAGE CONTENT-->
